package beans;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Date;

import org.apache.tomcat.dbcp.dbcp.BasicDataSource;

public class AdminBean {
	
	private static final long ONEDAY = 1000 * 60 * 60 * 24; 
	private static final double INCREASINGFACTOR = 1.3;
	private static final double DECREASINGFACTOR = 0.5;
	
	public static class TopOffer
	{
		private String title, aboutOffer; 
		private int idOffer, numberOfReservations;
		private double price;
		
		public TopOffer() {
		}

		public TopOffer(String title, String aboutOffer, double price, int numberOfReservations, int idOffer) {
			this.title = title;
			this.aboutOffer = aboutOffer;
			this.price = price;
			this.numberOfReservations = numberOfReservations;
			this.idOffer = idOffer;
		}

		public String getTitle() {
			return title;
		}

		public void setTitle(String title) {
			this.title = title;
		}

		public String getAboutOffer() {
			return aboutOffer;
		}

		public void setAboutOffer(String aboutOffer) {
			this.aboutOffer = aboutOffer;
		}

		public double getPrice() {
			return price;
		}

		public void setPrice(double price) {
			this.price = price;
		}

		public int getNumberOfReservations() {
			return numberOfReservations;
		}

		public void setNumberOfReservations(int numberOfReservations) {
			this.numberOfReservations = numberOfReservations;
		}

		public int getIdOffer() {
			return idOffer;
		}

		public void setIdOffer(int idOffer) {
			this.idOffer = idOffer;
		}	
		
	}
	
	public static class TopCompany
	{
		private int companyId, numberOfReservations;
		private String name, pib;
		
		
		public TopCompany() {
		}
		
		public TopCompany(int companyId, int numberOfReservations, String name,
				String pib) {
			this.companyId = companyId;
			this.numberOfReservations = numberOfReservations;
			this.name = name;
			this.pib = pib;
		}

		public int getNumberOfReservations() {
			return numberOfReservations;
		}

		public void setNumberOfReservations(int numberOfReservations) {
			this.numberOfReservations = numberOfReservations;
		}

		public int getCompanyId() {
			return companyId;
		}
		public void setCompanyId(int companyId) {
			this.companyId = companyId;
		}
		public String getName() {
			return name;
		}
		public void setName(String name) {
			this.name = name;
		}
		public String getPib() {
			return pib;
		}
		public void setPib(String pib) {
			this.pib = pib;
		}
		
		
	}

	public static class Reservation
	{
		private int resId;
		private int userId;
		private String title;
		private String description;
		private String user;
		public int getResId() {
			return resId;
		}
		public void setResId(int resId) {
			this.resId = resId;
		}
		public String getTitle() {
			return title;
		}
		public void setTitle(String title) {
			this.title = title;
		}
		public String getDescription() {
			return description;
		}
		public void setDescription(String description) {
			this.description = description;
		}
		public String getUser() {
			return user;
		}
		public void setUser(String user) {
			this.user = user;
		}
		
		public int getUserId() {
			return userId;
		}
		public void setUserId(int userId) {
			this.userId = userId;
		}
		public Reservation(int resId, String title, String description,
				String user) {
			this.resId = resId;
			this.title = title;
			this.description = description;
			this.user = user;
		}
		public Reservation() {
		}
	}
	
	public static class NewCompany
	{
		private String name;
		private String username;
		private String pib;
		private int reqId;
		
		
		public NewCompany(String name, String username, String pib, int reqId) {
			this.name = name;
			this.username = username;
			this.pib = pib;
			this.reqId = reqId;
		}
		public NewCompany() {
		}
		public String getName() {
			return name;
		}
		public void setName(String name) {
			this.name = name;
		}
		public String getUsername() {
			return username;
		}
		public void setUsername(String username) {
			this.username = username;
		}
		public String getPib() {
			return pib;
		}
		public void setPib(String pib) {
			this.pib = pib;
		}
		public int getReqId() {
			return reqId;
		}
		public void setReqId(int reqId) {
			this.reqId = reqId;
		}	
	}
	
	public static class TopUser
	{
		private String name, surname, city;
		private int numberOfReservations, idUser;
		double buyingParam;
		
		public TopUser() {
		}
		
		public TopUser(String name, String surname, String city,
				int numberOfReservations, int idUser, double buyingParam) {
			this.name = name;
			this.surname = surname;
			this.city = city;
			this.numberOfReservations = numberOfReservations;
			this.idUser = idUser;
			this.buyingParam = buyingParam;
		}

		public String getCity() {
			return city;
		}

		public void setCity(String city) {
			this.city = city;
		}

		public double getBuyingParam() {
			return buyingParam;
		}

		public void setBuyingParam(double buyingParam) {
			this.buyingParam = buyingParam;
		}

		public String getName() {
			return name;
		}
		public void setName(String name) {
			this.name = name;
		}
		
		public String getSurname() {
			return surname;
		}

		public void setSurname(String surname) {
			this.surname = surname;
		}

		public int getNumberOfReservations() {
			return numberOfReservations;
		}
		public void setNumberOfReservations(int numberOfReservations) {
			this.numberOfReservations = numberOfReservations;
		}

		public int getIdUser() {
			return idUser;
		}

		public void setIdUser(int idUser) {
			this.idUser = idUser;
		}
		
		
		
	}
	
	BasicDataSource ds;
	private ArrayList<Reservation> reservations;
	private ArrayList<NewCompany> newCompanies;
	private ArrayList<TopOffer> topOffers;
	private ArrayList<TopUser> topUsers;
	private ArrayList<TopCompany> topCompanies;
	
	private int selectedReservation;
	private int selectedUser;
	private int selectedRequiredCompany;
	
	public AdminBean(BasicDataSource ds) {
		this.ds = ds;
		reservations = new ArrayList<AdminBean.Reservation>();
		newCompanies = new ArrayList<AdminBean.NewCompany>();
		topOffers = new ArrayList<AdminBean.TopOffer>();
		topUsers = new ArrayList<AdminBean.TopUser>();
		topCompanies = new ArrayList<AdminBean.TopCompany>();
	}
	
	public void loadReservations()
	{
		reservations.clear();
		
		Connection cnn = null;
		Statement stat = null;
		ResultSet rs = null;
		
		try {
			cnn = ds.getConnection();
			stat = cnn.createStatement();
			String getReservations = "SELECT R.idReservations, O.title, O.aboutOffer, U.username, U.idUsers FROM offers O, users U, reservations R WHERE R.idUser = U.idUsers AND R.idOffer = O.idOffers " +
					"AND R.decided = false";
			
			//bilo je isConfirmed = false
			
			rs = stat.executeQuery(getReservations);
			while(rs.next())
			{
				int idRes = rs.getInt(1);
				String title = rs.getString(2);
				String about = rs.getString(3);
				String uname = rs.getString(4);
				int uid = rs.getInt(5);
				
				Reservation r = new Reservation();
				r.setResId(idRes);
				r.setDescription(about);
				r.setTitle(title);
				r.setUser(uname);
				r.setUserId(uid);
				reservations.add(r);
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
		finally
		{
			if(cnn != null)
			{
				try {
					cnn.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
			
			if(stat != null)
			{
				try {
					stat.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
		}
	}
	
	public void loadCompanies()
	{
		newCompanies.clear();
		
		Connection cnn = null;
		Statement stat = null;
		ResultSet rs = null;
		
		try {
			cnn = ds.getConnection();
			stat = cnn.createStatement();
			String getCompaniesQuery = "SELECT idRequiredCompanies, username, name, PIB FROM requiredcompanies";
			rs = stat.executeQuery(getCompaniesQuery);
			while(rs.next())
			{
				int reqId = rs.getInt(1);
				String uname = rs.getString(2);
				String name = rs.getString(3);
				String pib = rs.getString(4);
				
				NewCompany c = new NewCompany(name, uname, pib, reqId);
				newCompanies.add(c);
			}
			
		} catch (SQLException e) {
			e.printStackTrace();
		}
		finally
		{
			if(cnn != null)
			{
				try {
					cnn.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
			
			if(stat != null)
			{
				try {
					stat.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
		}
		
	}

	public ArrayList<Reservation> getReservations() {
		return reservations;
	}

	public void setReservations(ArrayList<Reservation> reservations) {
		this.reservations = reservations;
	}
	
	
	public String acceptPayment()
	{
		Connection cnn = null;
		
		try {
			cnn = ds.getConnection();
			if(isRegularyPaid(cnn))
			{
				updateReservations(cnn);
				changeBuyingParameter(cnn, INCREASINGFACTOR, selectedUser);
				updateDecided(cnn);
				loadReservations();
				return null;
			}
			else
			{
				loadReservations();
				changeBuyingParameter(cnn, DECREASINGFACTOR, selectedUser);
				doBlocking(cnn);
				updateDecided(cnn);
				return null;
			}
			
		} catch (SQLException e) {
			e.printStackTrace();
		}
		finally
		{
			if(cnn != null)
			{
				try {
					cnn.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}			
			}
		}
		return null;
	}
	
	public String declinePayment()
	{
		Connection cnn = null;
		try {
			cnn = ds.getConnection();
			changeBuyingParameter(cnn, DECREASINGFACTOR, selectedUser);
			doBlocking(cnn);
			updateDecided(cnn);
			loadReservations();
		} catch (SQLException e) {
			e.printStackTrace();
		}
		finally
		{
			if(cnn != null)
			{
				try {
					cnn.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}

		}
		
		return null;
	}
	
	public void doBlocking(Connection cnn) throws SQLException
	{
		Statement stat = cnn.createStatement();
		String query = "SELECT unusedReservations FROM registrateduser WHERE idRegistratedUser = " + selectedUser;
		ResultSet rs = stat.executeQuery(query);
		rs.next();
		int unused = rs.getInt(1);
		stat.close();
		stat = cnn.createStatement();
		String updateQuery;
		if(unused < 3)
		{
			updateQuery = "UPDATE registrateduser SET unusedReservations = " + (unused + 1) + " WHERE idRegistratedUser = " + selectedUser;
		}
		else
		{
			updateQuery = "UPDATE registrateduser SET isBlocked = true WHERE idRegistratedUser = " + selectedUser;
		}
		
		stat.executeUpdate(updateQuery);
		stat.close();
	}

	private boolean isRegularyPaid(Connection conn) throws SQLException
	{
		Statement stat = null;
		ResultSet rs = null;
		
		stat = conn.createStatement();
		String getReservationDate = "SELECT dateReserved, numberReserved FROM reservations WHERE idReservations = " + selectedReservation;
		rs = stat.executeQuery(getReservationDate);
		rs.next();
		
		java.sql.Date resDat = rs.getDate(1);
		long resTime = resDat.getTime();
		
		Date now = new Date();
		long nowTime = now.getTime();
		
		long diff = nowTime - resTime;
		stat.close();
		if(diff > ONEDAY)
		{
			return false;
		}
		else
		{
			return true;
		}
	}
	
	private void changeBuyingParameter(Connection cnn, double factor, int userId) throws SQLException
	{
		Statement stat = cnn.createStatement();
		String getOldParam = "SELECT buyingParameter FROM registrateduser WHERE idRegistratedUser = " + userId;
		ResultSet rs = stat.executeQuery(getOldParam);
		rs.next();
		double old = rs.getDouble(1);

		old *= factor;
		
		stat.close();
		stat = cnn.createStatement();
		String updateUser = "UPDATE registrateduser SET buyingParameter = " + old + " WHERE idRegistratedUser = " + selectedUser;
		stat.executeUpdate(updateUser);
		stat.close();
	}
	
	private void updateReservations(Connection cnn) throws SQLException
	{
		Statement stat = cnn.createStatement();
		String update = "UPDATE reservations SET isConfirmed = true WHERE idReservations = " + selectedReservation;
		stat.executeUpdate(update);
		stat.close();
		stat = cnn.createStatement();
		String updateUserUnusedRes = "UPDATE registrateduser SET unusedReservations = 0 WHERE idregistratedUser = " + selectedUser;
		stat.executeUpdate(updateUserUnusedRes);
		stat.close();
	}
	
	private void updateDecided(Connection cnn) throws SQLException
	{
		Statement stat = cnn.createStatement();
		String update = "UPDATE reservations SET decided = true WHERE idReservations = " + selectedReservation;
		stat.executeUpdate(update);
	}
	
	public String acceptCompanyApplication()
	{
		Connection cnn = null;
		Statement stat = null;
		ResultSet rs = null;
		
		try {
			cnn = ds.getConnection();
			stat = cnn.createStatement();
			String getThisCompany = "SELECT * FROM requiredcompanies WHERE idRequiredCompanies = " + selectedRequiredCompany;
			rs = stat.executeQuery(getThisCompany);
			rs.next();
			String username = rs.getString("username");
			String password = rs.getString("password");
			String name = rs.getString("name");
			String address = rs.getString("address");
			String city = rs.getString("city");
			String phone = rs.getString("phone");
			String mail = rs.getString("mail");
			String web = rs.getString("webSite");
			String pib = rs.getString("PIB");
			String giro = rs.getString("giroAccount");
			String activity = rs.getString("activityDescription");
			int ct1 = rs.getInt("companyType1");
			int ct2 = rs.getInt("companyType2");
			int ct3 = rs.getInt("companyType3");
			rs.close();
			stat.close();
			int primaryKey = insertIntoUsersTable(cnn, username, password);
			String intoCompanyString = "INSERT INTO company VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
			PreparedStatement intoCompany = cnn.prepareStatement(intoCompanyString);
			intoCompany.setInt(1, primaryKey);
			intoCompany.setNString(2, name);
			intoCompany.setNString(3, address);
			intoCompany.setNString(4, city);
			intoCompany.setNString(5, phone);
			intoCompany.setNString(6, mail);
			intoCompany.setNString(7, web);
			intoCompany.setNString(8, pib);
			intoCompany.setNString(9, giro);
			intoCompany.setNString(10, activity);
			intoCompany.setInt(11, ct1);
			intoCompany.setInt(12, ct2);
			intoCompany.setInt(13, ct3);
			
			intoCompany.executeUpdate();
			removeFromRequiredCompanies();
			
		} catch (SQLException e) {
			e.printStackTrace();
		}
		finally
		{
			if(cnn != null)
			{
				try {
					cnn.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
			
			if(stat != null)
			{
				try {
					stat.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
			
			if(rs != null)
			{
				try {
					rs.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
		}
		
		
		loadCompanies();
		return null;
	}
	
	private int insertIntoUsersTable(Connection cnn, String username, String password) throws SQLException
	{
		String inUsersQuery = "INSERT INTO users(username, password, userType) VALUES(?, ?, 'C')";
		PreparedStatement intoUsers = cnn.prepareStatement(inUsersQuery, Statement.RETURN_GENERATED_KEYS);
		intoUsers.setNString(1, username);
		intoUsers.setNString(2, password);
		intoUsers.executeUpdate();
		ResultSet rs = intoUsers.getGeneratedKeys();
		rs.next();
		int key = rs.getInt(1);
		intoUsers.close();
		rs.close();
		return key;
	}
	
	public String refuseCompanyApplication()
	{
		removeFromRequiredCompanies();
		loadCompanies();
		return null;
	}
	
	private void removeFromRequiredCompanies()
	{
		Connection cnn = null;
		Statement stat = null;
		
		try {
			cnn = ds.getConnection();
			stat = cnn.createStatement();
			String removeString = "DELETE FROM requiredcompanies WHERE idRequiredCompanies = " + selectedRequiredCompany;
			stat.executeUpdate(removeString);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		finally
		{
			if(cnn != null)
			{
				try {
					cnn.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
			
			if(stat != null)
			{
				try {
					stat.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
		}
	}
	
	public void loadTopCompanies()
	{
		topCompanies.clear();
		
		Connection cnn = null;
		PreparedStatement stat = null;
		ResultSet rs = null;
		
		try {
			cnn = ds.getConnection();
			loadBestCompanyIds(cnn);
			String getCompanyInfo = "SELECT name, PIB FROM company WHERE idCompany = ?";
			for(int i = 0; i < topCompanies.size(); i++)
			{
				stat = cnn.prepareStatement(getCompanyInfo);
				int compId = topCompanies.get(i).getCompanyId();
				stat.setInt(1, compId);
				rs = stat.executeQuery();
				rs.next();
				String name = rs.getString(1);
				String pib = rs.getString(2);
				
				topCompanies.get(i).setName(name);
				topCompanies.get(i).setPib(pib);
			}
			
		} catch (SQLException e) {
			e.printStackTrace();
		}
		finally
		{
			if(cnn != null)
			{
				try {
					cnn.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
			
			if(stat != null)
			{
				try {
					stat.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
			
			if(rs != null)
			{
				try {
					rs.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
		}
		
	}
	
	public void loadTopUsers()
	{
		topUsers.clear();
		Connection cnn = null;
		PreparedStatement stat = null;
		ResultSet rs = null;
		
		try {
			cnn = ds.getConnection();
			loadTopUsersIds(cnn);
			String getUser = "SELECT name, surname, city, buyingParameter FROM registrateduser WHERE idRegistratedUser = ?";
			for(int i = 0; i < topUsers.size(); i++)
			{
				stat = cnn.prepareStatement(getUser);
				int userid = topUsers.get(i).getIdUser();
				stat.setInt(1, userid);
				rs = stat.executeQuery();
				rs.next();
				String name = rs.getString(1);
				String surname = rs.getString(2);
				String city = rs.getString(3);
				double param = rs.getDouble(4);
				
				topUsers.get(i).setBuyingParam(param);
				topUsers.get(i).setCity(city);
				topUsers.get(i).setName(name);
				topUsers.get(i).setSurname(surname);
				
				stat.close();
				rs.close();
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
		finally
		{
			if(cnn != null)
			{
				try {
					cnn.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
			
			if(stat != null)
			{
				try {
					stat.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
			
			if(rs != null)
			{
				try {
					rs.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
		}
	}
	
	public void loadTopOffers()
	{
		loadBestOffersIds();
		Connection cnn = null;
		PreparedStatement stat = null;
		ResultSet rs = null;
		
		try {
			cnn = ds.getConnection();
			for(int i = 0; i < topOffers.size(); i++)
			{
				String getOfferInfo = "SELECT title, aboutOffer, price, discountPrice, hasDiscount FROM offers WHERE idOffers = ?";
				stat = cnn.prepareStatement(getOfferInfo);
				int id = topOffers.get(i).getIdOffer();
				stat.setInt(1, id);
				rs = stat.executeQuery();
				rs.next();
				String title = rs.getString(1);
				String about = rs.getString(2);
				double price = rs.getDouble(3);
				double dprice = rs.getDouble(4);
				boolean discount = rs.getBoolean(5);
				
				topOffers.get(i).setAboutOffer(about);
				topOffers.get(i).setTitle(title);
				if(!discount)
				{
					topOffers.get(i).setPrice(price);
				}
				else
				{
					topOffers.get(i).setPrice(dprice);
				}
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
		finally
		{
			if(cnn != null)
			{
				try {
					cnn.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
			
			if(stat != null)
			{
				try {
					stat.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
			
			if(rs != null)
			{
				try {
					rs.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
		}
	}
	
	private void loadBestOffersIds()
	{
		Connection cnn = null;
		Statement stat = null;
		ResultSet rs = null;
		
		try {
			cnn = ds.getConnection();
			stat = cnn.createStatement();
			String getTopOffersQuery = "SELECT * FROM (SELECT idOffer, SUM(numberReserved) FROM reservations GROUP BY idOffer ORDER BY numberReserved DESC) AS T1 LIMIT 0,10";
			rs = stat.executeQuery(getTopOffersQuery);
			while(rs.next())
			{
				int offerId = rs.getInt(1);
				int numberOfRes = rs.getInt(2);
				TopOffer o = new TopOffer();
				o.setIdOffer(offerId);
				o.setNumberOfReservations(numberOfRes);
				topOffers.add(o);
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
		finally
		{
			if(cnn != null)
			{
				try {
					cnn.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
			
			if(stat != null)
			{
				try {
					stat.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
			
			if(rs != null)
			{
				try {
					rs.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
		}
		
	}
	
	private void loadBestCompanyIds(Connection cnn) throws SQLException
	{
		Statement stat = cnn.createStatement();
		String query = "SELECT * FROM (SELECT idCompany, SUM(numberReserved) FROM (SELECT * FROM reservations R, offers GROUP BY R.idOffer) AS T1 " +
				"GROUP BY idCompany ORDER BY numberReserved DESC) AS T2 LIMIT 0,10";
		
		ResultSet rs = stat.executeQuery(query);
		while(rs.next())
		{
			int cid = rs.getInt(1);
			int res = rs.getInt(2);
			
			TopCompany tc = new TopCompany();
			tc.setCompanyId(cid);
			tc.setNumberOfReservations(res);
			tc.setCompanyId(cid);
			topCompanies.add(tc);
		}
		
		stat.close();
		rs.close();
	}
	
	private void loadTopUsersIds(Connection cnn) throws SQLException
	{
		Statement stat = cnn.createStatement();
		String getTopUsers = "SELECT * FROM (SELECT idUser, SUM(numberReserved) FROM reservations GROUP BY idUser ORDER BY numberReserved DESC) AS T1 LIMIT 0,10";
		ResultSet rs = stat.executeQuery(getTopUsers);
		while(rs.next())
		{
			TopUser u = new TopUser();
			int uid = rs.getInt(1);
			int num = rs.getInt(2);
			u.setIdUser(uid);
			u.setNumberOfReservations(num);
			topUsers.add(u);
		}
		stat.close();
		rs.close();
	}
	
	public int getSelectedReservation() {
		return selectedReservation;
	}

	public void setSelectedReservation(int selectedReservation) {
		this.selectedReservation = selectedReservation;
	}

	public int getSelectedUser() {
		return selectedUser;
	}

	public void setSelectedUser(int selectedUser) {
		this.selectedUser = selectedUser;
	}

	public ArrayList<NewCompany> getNewCompanies() {
		return newCompanies;
	}

	public void setNewCompanies(ArrayList<NewCompany> newCompanies) {
		this.newCompanies = newCompanies;
	}

	public int getSelectedRequiredCompany() {
		return selectedRequiredCompany;
	}

	public void setSelectedRequiredCompany(int selectedRequiredCompany) {
		this.selectedRequiredCompany = selectedRequiredCompany;
	}

	public ArrayList<TopOffer> getTopOffers() {
		return topOffers;
	}

	public void setTopOffers(ArrayList<TopOffer> topOffers) {
		this.topOffers = topOffers;
	}

	public ArrayList<TopUser> getTopUsers() {
		return topUsers;
	}

	public void setTopUsers(ArrayList<TopUser> topUsers) {
		this.topUsers = topUsers;
	}

	public ArrayList<TopCompany> getTopCompanies() {
		return topCompanies;
	}

	public void setTopCompanies(ArrayList<TopCompany> topCompanies) {
		this.topCompanies = topCompanies;
	}
	
	
}
